<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/pages/common/header.jsp"%>
</head>
<body>
	<div class="contentBody contentborder">
		<div class="tab-pane" id="tabPane">
			<div id="message">${message }</div>
			<div class="tab-page">
				 <h1 class="tab">订单选择</h1>
 				 <div class="contentborder">
                	 <jdf:form bean="request" scope="request">
						<form action="${dynamicDomain}/order/${action}?ajax=1&customerId=${params.customerId}" method="post">
						  <input type="hidden" name="from">
							 <table class="inputTable">
							     <c:if test="${empty params.customerId}">
							     <tr>
                                    <td nowrap class="label cancelBorderLeft">
                                        <label for="search_EQI_customerId">客户：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <select name="search_EQI_customerId" style="width: 400px;" id="search_EQI_customerId">
                                            <option value=""></option>
                                            <jdf:selectCollection items="customers" optionValue="objectId" optionText="name"/>
                                        </select>
                                    </td>
                                </tr>
                                </c:if>
			                 	<tr>
									<td nowrap class="label cancelBorderLeft">
										<label for="search_EQI_objectId">编号：</label>
									</td>
									<td class="content">
										<input type="text" name="search_EQI_objectId" />
									</td>
									<td nowrap class="label">
										<label for="search_GED_orderDate">订单日期：</label>
									</td>
									<td class="content">
										<input type="text" id="search_GED_orderDate" size="12" name="search_GED_orderDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'search_LED_orderDate\')}',readOnly:true})">
										~
									    <input type="text" id="search_LED_orderDate" size="12" name="search_LED_orderDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'search_GED_orderDate\')}',readOnly:true})">
									</td>
			                 	</tr>
			                 	<tr>
                                	<td class="bottomLabel" nowrap colspan="4">
                                		<div class="right">
											<button type="reset">重置</button>
											<button type="submit">查询</button>
                                		</div>
									</td>
			                 </table>
			            </form>
			        </jdf:form>
				</div>
				<div class="contentborder listArea">
					<div class="toolBar">
                        <button type="button" onclick="javascript:select();">确认</button>
                    </div>
					<div id="tableDiv">
						<jdf:table items="items" var="currentRowObject" retrieveRowsCallback="limit" filterRowsCallback="limit" sortRowsCallback="limit" action="${action}?ajax=1">
							<jdf:export view="csv" fileName="订单.csv" tooltip="Export CSV" imageName="csv" />
							<jdf:export view="xls" fileName="订单.xls" tooltip="Export EXCEL" imageName="xls" />
							<jdf:row>
							    <jdf:column property="id" title="<input type='checkbox' class='noBorder' name='pchk' onclick='pchkClick()'" style="width: 5%;text-align: center;padding: 0" sortable="false">
                                    <script>
                                        document.write("<input type='checkbox' class='noBorder' name='schk' value='${currentRowObject.objectId}' onclick='schkClick()'><input type='hidden' name='customerId' value='${currentRowObject.customerId}'>")
                                    </script>
                                </jdf:column>
								<jdf:column property="orderNo" title="编号" style="width: 15%" />
								<jdf:column property="orderDate" title="订单日期" style="width: 12%" cell="date"/>
								<jdf:column property="customerId" title="客户" style="width: 25%">
                                  <jdf:columnCollectionValue items="customers"  nameProperty="name" value="${currentRowObject.customerId}"/>(${currentRowObject.customerNo})
                                </jdf:column>
                                <jdf:column property="clientPo" title="客人订单编号" style="width: 14%"/>
								<jdf:column property="total" title="总计" style="width: 12%" cell="currency"/>
								<jdf:column property="quantity" title="数量" style="width: 8%"/>
								<jdf:column property="salesId" title="销售员" style="width: 8%">
									<jdf:columnCollectionValue items="users" nameProperty="userName" value="${currentRowObject.salesId}"/>
								</jdf:column>
							</jdf:row>
						</jdf:table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		function select(){
			var customerId="${params.customerId}";
			var ok = true;
			$('input[name="schk"]:checked').each(function(){
				if(customerId==""){
					customerId = $(this).next().val();
				} else {
					if(customerId != $(this).next().val()){
						showMessage("只能选择同一个客户的订单",60000);
						ok = false;
						return false;
					}
				}
			});
           
           if(ok){
        	   var orderId = getCheckedValuesString(document.getElementsByName("schk"));
        	   if(orderId==null){
                   showMessage("请至少选择一个订单",60000);
                   return false;
               }else{
                   parent.$("#orderId").val(orderId).change();
                   parent.$("#orderNo").val(orderId).change();
                   <c:if test="${empty params.customerId}">
                   parent.$("#customerId").val(customerId);
                   </c:if>
                   parent.jQuery.fn.colorbox.close();
               }
           }
		}
		
	</script>
</body>
</html>